#######################################################################
##### REPLICATION ARCHIVE: RACIAL ISOLATION DRIVES RACIAL VOTING ######
####################### POLITICAL BEHAVIOR ############################
################ MELISSA SANDS, DANIEL DE KADT, 2019 ##################
#######################################################################

#Please contact us if you find any issues: mlsands@gmail.com, ddekadt@gmail.com
#
#This archive is in three parts. There are files that relate to the aggregate analyses, files that relate to the individual analyses, and files that relate to the title deeds analyses in the appendix. To use the replication code as is, deposit all the files in a working directory. Add that working directory to the relevant Stata and R scripts as instructed in the code. Please create a folder in your working directory called "results." (Note: the resulting filenames do not correspond to the table and figure numbers in the paper or the appendix. Comments in the code indicate the correspondence with the outputs)

###
#The aggregate analyses require the following files: 
###
1) aggregate_data.dta
The replication dataset for the ward-level analysis:
  obs:         4,277                          
 vars:            35                          4 Mar 2019 16:18
 size:       881,062                          

2) aggregate_analysis.do
Stata code for replicating Tables 1 and 2 in the paper, and the appendix aggregate tables.

###
#The individual analyses require the following files: 
###
1) individual_data.dta
The replication data for individual analyses of South Africans:
  obs:        39,168                          
 vars:            40                          4 Mar 2019 16:25
 size:     7,011,072          
                     
2) rugplot_data.dta
The rugplot data for marginal effects plot
  obs:        42,004                          Written by R.              
 vars:             3                          
 size:     1,008,096                          

3) individual_analysis.do
Stata code for replicating Table 3 in the paper, and the appendix individual tables.

4) margin_effects_plot.R
R code for replicating Figure 3 in the paper. Use only after running individual_analysis.do.

###
#The title deeds analyses require the following files: 
###
1) titledeeds_aggregate_data.csv
The replication dataset for title deeds analyses at the ward level.
  obs:           899                          
 vars:             8                          
 size:        68,324 

2) title_deeds_analysis.R
R code for replicating Section I tables in the appendix.